package com.careerraiser.xtra.thread;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class TestCallable {

	public static void main(String[] args) {
		MyCallable clb1 = new MyCallable();
		ExecutorService exec = Executors.newCachedThreadPool();
		Future<Long> myfuture = exec.submit(clb1);
		Long output=null;
		while (! myfuture.isDone()){
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			System.out.println("Checking if future is ready");
		}
		try {
			output = myfuture.get();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println("output : " + output);
	}

}
